// pages/mine/problems/problems.js
const app = getApp();
var url = app.globalData.url;
Page({

  /**
   * 页面的初始数据
   */
  data: {
  
  },
  detail:function(e){
    console.log(e);
    var name = e.currentTarget.dataset.name;
    var id = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: '../problems/detail/detail?id='+id,
      success: function(res) {
        wx.setNavigationBarTitle({
          title: name,
          success: function(res) {},
          fail: function(res) {},
          complete: function(res) {},
        })
      },
      fail: function(res) {},
      complete: function(res) {},
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    //常见问题
    wx.request({
      url: url+'getQuestionAll',
      data: {
      },
      header: {
        "Content-Type": "application/json"
      },
      success: function (res) {
        console.log(res.data.object)
        that.setData({
          list:res.data.object
        })
      }
    })
     //阳光农场热线电话
    wx.request({
      url: url+'getCyShopTel',
      data: {
      },
      header: {
        "Content-Type": "application/json"
      },
      success: function (res) {
        console.log(res.data.object)
        that.setData({
          shopphone: res.data.object
        })
      }
    })
    //楚阳集团售后服务电话
    wx.request({
      url: url+'getCyCompanyTel',
      data: {
        qid:1
      },
      header: {
        "Content-Type": "application/json"
      },
      success: function (res) {
        console.log(res.data.object);
        that.setData({
          companyphone: res.data.object
        })
      }
    })
  },
  shopphone:function(e){
    console.log(e);
    var phone = e.currentTarget.dataset.id;
      wx.makePhoneCall({
        phoneNumber: phone,   
          success: function () {
            console.log("拨打电话成功！")
          },
          fail: function () {
            console.log("拨打电话失败！")
          }
        })  
  },
  companyphone: function (e) {
    console.log(e);
    var phone = e.currentTarget.dataset.id;
    wx.makePhoneCall({
      phoneNumber: phone,
      success: function () {
        console.log("拨打电话成功！")
      },
      fail: function () {
        console.log("拨打电话失败！")
      }
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})